home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 6135 < prev    next >
Encoding:
Text File  |  1996-08-05  |  3.1 KB  |  128 lines

  1. Path: tank.news.pipex.net!pipex!demon!le-vamp.demon.co.uk
  2. From: Kurt@le-vamp.demon.co.uk (Kurt Frary)
  3. Newsgroups: comp.lang.c++
  4. Subject: Is anyone good enough to solve this ?
  5. Date: Sun, 11 Feb 1996 21:37:03 GMT
  6. Message-ID: <824074487.16609@le-vamp.demon.co.uk>
  7. Reply-To: kurt@le-vamp.demon.co.uk
  8. NNTP-Posting-Host: le-vamp.demon.co.uk
  9. X-NNTP-Posting-Host: le-vamp.demon.co.uk
  10. X-Newsreader: Forte Agent .99c/32.126
  11.  
  12. Here is a program that works, it writes a message on the screen,
  13. changes screen modes, plots three points and then writes another
  14. message and terminates.
  15.  
  16.  It is a 32 bit flat model program running under DOS/4GW.
  17.  
  18. Question: Why will it not work if I take out the first cout and give a
  19. GPF ?
  20.  
  21. #include <iostream.h>
  22. #include <iomanip.h>
  23.  
  24. #include  <stdio.h>
  25. #include  <dos.h>
  26. #include  <conio.h>
  27. #include  <math.h>
  28.  
  29. // don't do this for C stuff !!!!!
  30. //#pragma aux default parm []; 
  31. void scrmode(char scrmode);
  32.  
  33. // Lets make this neat code, Calculate the screens linear address!
  34.      #define SCREEN_AREA 0xa000
  35.      #define SCREEN_LIN_ADDR ((SCREEN_AREA) << 4)
  36.      #define SCREEN_SIZE 320*200
  37.  
  38.      #define SCREEN_MODE 0x449
  39.  
  40.      
  41. // Here we Go !!!!!
  42. void main(void)
  43. {
  44.         cout << "Program Now Running" << endl;
  45. // Wait for user to press a key:
  46. //        while (!kbhit());
  47.  
  48.  
  49. // Store previous Screen mode
  50. //        int oldmode=(int *)MK_FP(0x40,0x49); 16 bit method
  51. // Create oldmode of Char format equal to address of char pointer
  52. screen_mode.
  53.         char oldmode=* (char *) SCREEN_MODE;
  54.         
  55. // Set the bloody screen mode, kf coding style
  56.         scrmode(0x13);
  57.  
  58. // Set the screen pointer, like 16 bit but shift left 4 (16 bits for
  59. flat model)
  60. //        char *screen = (char *) ((0xa000 <<4));  but as this is neat
  61. code!!!
  62.         char *screen = (char *) SCREEN_LIN_ADDR;
  63.  
  64.  
  65. //Define Table to store points in
  66. #define nocoords 2  // 2=just x and y
  67. #define nopoints 3  // 3 sets of coords
  68.  
  69. char xcoord=0;
  70. char ycoord=1;
  71. short int centrex,centrey;
  72. short int i;
  73.  
  74. int offset; // 4 bytes for offset
  75. short int startx,starty ; // short int 0 to 65535 (2 Bytes)
  76.  
  77. centrex=160;
  78. centrey=100;
  79.  
  80. // Table of points, (short int 2 bytes (0 to 65535))
  81.         short int point [nopoints][nocoords]={
  82.         140,80,
  83.         142,80,
  84.         144,80
  85.         };
  86.  
  87.         
  88. // We now need an external loop to rotate the points using F
  89. //        for (unsigned int angle=1; angle<=360; angle+=10)
  90. //        {
  91.  
  92. // This is the loop to plot the points using i
  93.         char colour=11;
  94.         for (i=0; i<nopoints; i++)
  95.         {
  96.             
  97. // Set starting coordinates for point
  98.         startx=point[i][xcoord];
  99.         starty=point[i][ycoord];
  100.  
  101. // Calculate video memory offset of coordinates:
  102.         offset=starty*320+startx;
  103.  
  104. // Draw the point
  105.         screen[offset]=colour;
  106.  
  107. // Increase the colour
  108.         colour++;
  109.         }
  110.  
  111.  
  112. // Wait for user to press a key:
  113.         while (!kbhit());
  114.  
  115.         scrmode(oldmode);
  116.         
  117.         cout << "Program Terminated Correctly" << endl;
  118.         printf("kurt");
  119. }
  120.  
  121.  
  122.  
  123.  Kurt Frary
  124.   Kurt@le-vamp.demon.co.uk
  125.  
  126. Life is like a woman, you enjoy yourself, get fucked and then your fucked!
  127.  
  128.